<template>
    <div>
   <h1>登录</h1>
    </div> 
    <table class="table">
        <thead>
            <tr>
                <td>用户名</td>
                 <td>
                    <input type="text" v-model="data.name">
                 </td>
            </tr>

              <tr>
                <td>密码</td>
                 <td>
                        <input type="text" v-model="data.pwd">
                 </td>
            </tr>

              <tr>
                <td></td>
                 <td>
                    <input type="button" value="登录" @click="loin()">
                 </td>
            </tr>
        </thead>
    </table>
</template>

<script setup lang="ts">
   import axios from 'axios';
    import {ref,onMounted} from 'vue';
import{useRouter} from 'vue-router';

import {useUserStore} from '@/stores/usermager';

 const user=useUserStore();

 const  router=useRouter(); 

  const data=ref({

      name:'',
      pwd:'',

  })

 const loin=()=>{

     axios.get("https://localhost:7103/api/UserMager/Loing",{params:data.value}).then(res=>{
         if(res.data.userMagerId>0){
          
         alert("登录成功")

           user.userinfo.name=res.data.name;
           user.userinfo.pwd=res.data.pwd;

          router.push("/showw")

         }else{
                  alert("登录失败")
         }
     })
 }

</script>

<style scoped>

</style>
